<?php
include('../common/_const.php');
include('../common/common.php');
include('../common/checksession.php');
checksession("../index.php");
include('../../inc/conn.php');

$username		=$_POST['rootname'];
$pwd			=md5(PREPWD.$_POST['pwd']);
$npwd			=md5(PREPWD.$_POST['n_pwd']);
$nrpwd			=md5(PREPWD.$_POST['nr_pwd']);
$email			=$_POST['email'];
$gurl			=$_POST['gurl'];

if($npwd!=$nrpwd){
	ShowMsg("两次密码输入不一样！",$gurl);
	exit;
}

$db=db_connect();
$sql=select_sql("*",PRETABLE."adminuser","rootname='".$username."' AND rootpws='".$pwd."'");
$rs=$db->query($sql);
if($rs&&$rs->num_rows>0){
	$sql=update_sql("`".PRETABLE."adminuser`","`rootpws`='".$npwd."'","`rootname`='".$username."'");
	if($db->query($sql)){
		ShowMsg("修改成功！","../moduls/member.php");
	}else{
	ShowMsg("修改失败！",$gurl);
	exit;
	}
	
	
}else{
	ShowMsg("原始密码不正确！",$gurl);
	exit;
}
?>